# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=java-jffi
_pkgname=${pkgname#java-}
pkgver=1.2.23
_libver=${pkgver%.*}
pkgrel=0
pkgdesc="Java Foreign Function Interface"
url="https://github.com/jnr/jffi"
# arm* - InvokerTest fails
# ppc64le - segfaults in test
# x86 - one NumberTest fails
arch="all !armhf !armv7 !mips !mips64 !ppc64le !x86"
license="Apache-2.0"
depends="openjdk8-jre-base"
makedepends="apache-ant file openjdk8"
subpackages="$pkgname-native"
source="https://github.com/jnr/$_pkgname/archive/$_pkgname-$pkgver.tar.gz"
builddir="$srcdir/$_pkgname-$_pkgname-$pkgver"

build() {
	cd "$builddir"
	ant jar
}

check() {
	cd "$builddir"
	ant test
}

package() {
	depends="$pkgname-native"

	install -m644 -D "$builddir"/dist/jffi.jar \
		"$pkgdir"/usr/share/java/$_pkgname-$pkgver.jar || return 1
	ln -sf $_pkgname-$pkgver.jar "$pkgdir"/usr/share/java/$_pkgname.jar
}

native() {
	# Note: jffi expects file named libjffi-x.y.so, not libjffi.so.x.y.
	install -m755 -D "$builddir"/build/jni/libjffi-$_libver.so \
		"$subpkgdir"/usr/lib/libjffi-$_libver.so
}

sha512sums="991ccfb13487812187110a544737f6c78d8915f81a32cc6b53ad3417d7eb7ff3796849db66d29e4081ef10017b9d809b2b2918d942912cd3f9ed68e3b32ad498  jffi-1.2.23.tar.gz"
